package poker

import player.PlayerManager
import utile.POKER_NUMBER_LIST
import utile.POKER_SUIT_LIST
import kotlin.random.Random

class PokerManager {
    var pokers:ArrayList<Poker> = ArrayList()
    companion object{
        //单例对象
        val sharedManager: PokerManager by lazy(
            LazyThreadSafetyMode.SYNCHRONIZED) {
            PokerManager()
        }
    }
    init {
        for ((i,number) in POKER_NUMBER_LIST.withIndex()){
            for ((j,suit) in POKER_SUIT_LIST.withIndex()){
                pokers.add(
                    Poker(
                        number(number,i),
                        suit(suit,j)
                    )
                )
            }
        }
    }//创建好了一张牌
    fun getOnePoker():Poker{
        val index= Random.nextInt(pokers.size)
        val poker=pokers[index]
        pokers.removeAt(index)
        return  poker
    }//获得一张牌
    fun getSomePokers( count:Int):List<Poker>{
        var SomePokers:ArrayList<Poker> = arrayListOf()
        for(i in 1..count)
        {
            SomePokers.add(getOnePoker())
        }
        return SomePokers
    }
}